<template>
    <div class="port-page">
        <!-- 顶部按钮 -->
        <div class="but1">
        <router-link to="/home">
			<el-button type="warning" size="small"  style='margin-right: 5px;' icon="el-icon-menu">首页</el-button>
		</router-link>


        <el-button type="danger" size="small" v-if="this.visqy !='Y'" :disabled="multipleDeleteDisabled"  @click="shenhe">批量审核</el-button>
        </div>
        <!-- 模糊搜索条件 -->
        <div class="search">
        	<el-button type="text" size="small" class="add btn" style=' text-decoration:underline;' v-if="ss" @click='gd'>更多</el-button>
            <el-button type="text" size="small" class="add btn" style=' text-decoration:underline;' v-if="ss1" @click='gd1'>更多</el-button>
        	<div class="search-item">
            <el-tooltip  placement="top" class="sx">
      				<el-switch  @change="search()" v-model="visqy" active-color="#13ce66" inactive-color="#ff4949" inactive-text="待审" active-text="已审" active-value="Y" inactive-value="N"></el-switch>
      			</el-tooltip>
     			</div>
           <!--<div class="search-item">
                <el-date-picker  v-model="vbtime"  type="date" class="code-search"  placeholder="开始日期" @keyup.enter.native="search" icon="search"></el-date-picker>
            </div>
            <div class="search-item">
                  <el-date-picker  v-model="vetime"  type="date" class="code-search"  placeholder="结束日期" @keyup.enter.native="search" icon="search"></el-date-picker>
            </div>
            <span>-</span>-->
              <div class="search-item">
                <!--<span>单据号</span>-->
                <el-input placeholder="请输入学生名称" class="code-search" v-model="vkeyword"  @keyup.enter.native="search" icon="search"></el-input>
            </div>
            <el-button type="primary" class="add btn" size="small" style="border-radius:13px;" :loading="searchLoading" @click="search()" icon="el-icon-search"></el-button>
        </div>
        
        <div class="search1" v-if='aa'>
        	
        	<!--<div class="search-item" >
        		<span>审核状态</span>
        		<el-select v-model="visqy" @change="search" class="code-search">
                	<el-option label="所有" value=""></el-option>
                    <el-option label="已审核" value="Y"></el-option>
                    <el-option label="未审核" value="N"></el-option>
                </el-select>
     	    </div>-->
            <span>审核时间</span>
        	<div class="search-item">
                <el-date-picker  v-model="vbtime"  type="date" :editable="false" class="code-search"  placeholder="开始日期" @keyup.enter.native="search" icon="search"></el-date-picker>
            </div>
            <div class="search-item">
                <!--<span>结束时间：</span>-->
                  <el-date-picker  v-model="vetime"  type="date" :editable="false" class="code-search"  placeholder="结束日期" @keyup.enter.native="search" icon="search"></el-date-picker>
            </div>
            
        </div>
        <!-- 数据表格展示区域 -->
         <el-table
         	border
            stripe
            size="small"
    :data="dataList"
    style="width: 100%;text-align:center;"
    @select="checkSelect"
    @select-all="checkall">
    <el-table-column type="selection" width="35"></el-table-column>
   <el-table-column label="学生名称" width="100" align="center"  prop="zwm">
				 <template scope="scope">
                    <div slot="reference" >
                        <div v-if="scope.column.property == 'zwm'" @click="componentsShow('info',scope)">
                            <img :src="scope.row.xb == '男' ? $store.state.sexImg.boy : $store.state.sexImg.girl"
                            style="width:20px;vertical-align:middle; float: left;"
                            v-if="scope.column.property == 'zwm'">
                            <span style="vertical-align:middle;">{{ scope.row[scope.column.property] }}</span>
                        </div>
                        <span style="vertical-align:middle;" v-else>{{ scope.row[scope.column.property] }}</span>
                    </div>
                </template>
			</el-table-column>
			 <el-table-column
      	align="center"
        prop="zje"
        label="总金额"
        width="70">
      </el-table-column>
    <el-table-column align="center" label="现金支付" style="text-align: center;">
      <el-table-column
      	align="center"
        prop="xj"
        label="现金"
        width="60">
      </el-table-column>
      <!--<el-table-column
      	align="center"
        prop="yezf"
        label="余额"
        width="60">
      </el-table-column>-->
      <el-table-column
      	align="center"
        prop="yhj"
        label="优惠券"
        width="60">
      </el-table-column>
       <el-table-column
       	align="center"
        prop="zj"
        label="直减"
        width="60">
      </el-table-column>
      </el-table-column>
      
      
      <el-table-column align="center" label="第三方支付" style="text-align: center;">
      <el-table-column
      	align="center"
        prop="zffs"
        label="支付方式"
        width="70">
      </el-table-column>
      <el-table-column
      	align="center"
        prop="zfje"
        label="金额"
        width="60">
      </el-table-column>
      <el-table-column
      	align="center"
        prop="zfkh"
        label="账号"
        width="160">
      </el-table-column>
      </el-table-column>
      
       <el-table-column
    	align="center"
      prop="note"
      label="备注"
      width="">
    </el-table-column>
    </el-table-column>
   
     <el-table-column
    	align="center"
      prop="sj"
      label="支付时间"
      width="140">
    </el-table-column>
    </el-table-column>
    
    <el-table-column
    	align="center"
      prop="shzt"
      label="审核状态"
      width="90">
    </el-table-column>
    <el-table-column label="不通过原因" v-if="visqy=='Y'" align="center">
				<template scope="scope">
					<el-button size="small" type="text" style="color:#1F2D3D">{{scope.row.note}}</el-button>
				</template>
			</el-table-column>
    <el-table-column label="操作" width="210px"  align="center" :fixed="'right'" >
                <template scope="scope">
                   <!--<el-button size="mini" type="warning" v-if="scope.row.shzt == 'N'"  @click="shenhe2(scope.row.id)">审核</el-button>-->
                   <el-button size="mini" type="success"  @click="componentsShow('info1',scope)">详情</el-button>
                   <el-button size="mini" type="success" v-if="scope.row.shzt=='未审核'" @click="componentsShow('tg',scope)">通过</el-button>
                   <el-button size="mini" type="warning" v-if="scope.row.shzt=='未审核'" @click="componentsShow('btg',scope)">不通过</el-button>
                  <!--<el-button size="mini" type="success" v-if="scope.row.issh == 'Y'" disabled  >已审核</el-button>-->
                </template>
            </el-table-column>
            
  </el-table>
        <!-- 分页查询区域 -->
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="pageindex"
            :page-sizes="pagesizes"
            :page-size="pagesize"
            :layout="layout"
            :total="total"
            class="class-page">
        </el-pagination>
        <!-- 各个组件显示区域 -->
        <!-- 动画加载 -->
        <LoadingComponent v-show="isLoading"></LoadingComponent>
        <!-- 子路由显示区域 -->
        <info1Component v-if="portComponents.info1.toggle" @close="componentsHide" :params="portComponents.info1.params"></info1Component>
        <BtgComponent v-if="portComponents.btg.toggle" @close="componentsHide" :params="portComponents.btg.params"></BtgComponent>
        <TgComponent v-if="portComponents.tg.toggle" @close="componentsHide" :params="portComponents.tg.params"></TgComponent>
		<infoComponent v-if="portComponents.info.toggle" @close="componentsHide" :params="portComponents.info.params"></infoComponent>
        <router-view class="port-view"></router-view>
    </div>
</template>
<script>
    import { mapState } from 'vuex'
    import LoadingComponent from 'components/loading'
	import InfoComponent from '../../educa/classManage/student/info'
	import BtgComponent from './btg'
    import Info1Component from './info1'
    import TgComponent from './tg'
    import qs from 'qs'
    export default {
        components: {  LoadingComponent,InfoComponent,BtgComponent,TgComponent,Info1Component },
        data () {
            return {
            	aa:false,
			    ss:true,
			    ss1:false,
            	visqy:'N',
            	wpid:'',
                zt:1,
            /*模糊搜索条件*/
                vkeyword:'',
                vbtime:'',
                vetime:'',
				multipleDeleteDisabled:true,
				multipleDelNum:'', //获取批量选择的数据
                dataList: [],  //表格数据

				/*动画加载*/
                isLoading: true,//动画加载
                searchLoading: false,//搜索按钮触发按钮动画
                /*分页属性设置*/
                layout: 'total, sizes, prev, pager, next, jumper',//组件布局
			    pageindex: this.$store.state.pageindex,//当前分页页码
                pagesizes: this.$store.state.pagesizes,//显示个数的选择器选项
                pagesize: this.$store.state.pagesize,//每页显示条目数
                total: 0,//总条数

                /*组件区域*/
                portComponents: {
                    /* 单行删除  */
                    singleDelete: {
                        type: 'singleDelete',
                        toggle: false,
                        params: '',
                        data: {
                            index: '',
                            type: 'single',
                            title: '此操作将删除该记录?, 是否继续?'
                        }
                    },
                    /* 批量删除 */
                    multipleDelete: {
                        type: 'multipleDelete',
                        toggle: false,
                        params: '',
                        data: {
                            index: '',
                            type: 'multiple',
                            title: '此操作将删除您选中的记录?, 是否继续?'
                        }
                    },
                    /* 添加 */
//                  add: {
//                      type: 'add',
//                      toggle: false,
//                      params: '',
//                      data: {}
//                  },
                    /* 编辑 */
                    edit: {
                        type: 'edit',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                    /* info */
                    info: {
                        type: 'info',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                    info1: {
                        type: 'info1',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                    /*   sonpage   rkdmx   */
                    rkdmx: {
                        type: 'rkdmx',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                    btg: {
                        type: 'btg',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                    tg: {
                        type: 'tg',
                        toggle: false,
                        params: '',
                        data: {}
                    }
                },
                /*
                    prop :  接口参数名
                    label : 接口中文名
                    hide : 是否隐藏这一列
                    align : 这一列对齐顺序 ： left,right,center
                    headerAlign : 这一列表头对齐方式 ： left,right,center
                */
                portTitleList: [

                    {
                        prop:'zwm',
                        label:'学生名称',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'100',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },

                    {
                        prop:'xj',
                        label:'现金',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'yezf',
                        label:'余额支付',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'yhj',
                        label:'优惠卷',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'zj',
                        label:'直减金额',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },

                    {
                        prop:'zfbzh',
                        label:'支付宝',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },

                    {
                        prop:'zfbje',
                        label:'支付宝金额',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'100',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                      prop:'wxzh',
                      label:'微信',
                      hide:0,
                      align:'center',
                      fixed:false,
                      width:'',
                      minWidth:'',
                      headerAlign:'center',
                      formatter: function(row,column) {}
                    },
                     {
                        prop:'wxje',
                        label:'微信金额',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                     {
                        prop:'zje',
                        label:'总金额',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                     {
                        prop:'yhkje',
                        label:'银行卡金额',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'100',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'yhkzh',
                        label:'银行卡帐号',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'200',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'zffs',
                        label:'支付方式',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'zfje',
                        label:'支付金额',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'sj',
                        label:'支付时间',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'150',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'zfkh',
                        label:'支付卡号',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'200',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                   

                ]
            }
        },
        created () {
        	 var logininfo = JSON.parse(localStorage.logininfo) ;

            //加载页面时调用
            this.$store.dispatch('changeTitle','缴费审核');//修改title
            this.$store.dispatch('changeRouterIndex','/cost/jfsh');//修改路由
            this.search();//分页获取默认数据
            this.isLoading = true;//动画开始
        },
        mounted () {
            //加载完成之后event
            this.isLoading = false;//动画结束
        },
        methods: {
        	gd(){
        		this.aa=true;
        		this.ss=false;
        		this.ss1=true;
        	},
        	gd1(){
        		this.aa=false;
        		this.ss=true;
        		this.ss1=false;
        	},

          shenhe() {
            this.$confirm('此操作将审核所选账单, 是否继续?', '提示', {
    				 confirmButtonText: '确定',
    				 cancelButtonText: '取消',
    				 type: 'warning'
    			 }).then(() => {
             var arr = this.multipleDelNum
             // alert(arr)
      				this.$store.state.loading = true;
      				//装载数据
      				var logininfo = JSON.parse(localStorage.logininfo);
      				var params2 = qs.stringify({
      						ids:arr+'',
      					})
      				//执行
      				    this.axios.post(this.$store.state.api + 'xfjl/issh',  params2 )
      						.then(res => {
      							if(res.data.code == 1) {
      								this.$message.success(res.data.msg);
     // 								this.$emit('close', { type: 'btg', cancel: false });
                                     this.search();
                                     this.multipleDeleteDisabled = true;
      								this.$store.state.loading = false;
      							} else {
      								this.$message.warning(res.data.msg);
     // 								this.$emit('close', { type: 'btg', cancel: false });
      								this.$store.state.loading = false;
      							}
      						}).catch(res => {
      							this.$message.danger("服务器异常");
      							this.$store.state.loading = false;
      						})
    			 }).catch(() => {
    				 this.$message({
    					 type: 'info',
    					 message: '已取消'
    				 });
    			 });
     			},
          shenhe2(id) {
            this.$confirm('此操作将审核该账单, 是否继续?', '提示', {
    				 confirmButtonText: '确定',
    				 cancelButtonText: '取消',
    				 type: 'warning'
    			 }).then(() => {
      				this.$store.state.loading = true;
      				//装载数据
      				var logininfo = JSON.parse(localStorage.logininfo);
      				var params2 = qs.stringify({
      						ids:id,
      					})
      				//执行
      				    this.axios.post(this.$store.state.api + 'xfjl/issh',  params2 )
      						.then(res => {
      							if(res.data.code == 1) {
      								this.$message.success(res.data.msg);
                                    this.search();
      								this.$store.state.loading = false;
      							} else {
      								this.$message.warning(res.data.msg);
      								this.$store.state.loading = false;
      							}
      						}).catch(res => {
      							this.$message.danger("服务器异常");
      							this.$store.state.loading = false;
      						})
    			 }).catch(() => {
    				 this.$message({
    					 type: 'info',
    					 message: '已取消'
    				 });
    			 });
     			},
          search () {
		    //查询搜索触发事件
		    if(this.vbtime){
	          var time1 = this.$.getLocalTimeNo0(Date.parse(this.vbtime));
	          var time2 = this.$.getLocalTimeNo0(Date.parse(this.vetime));
	        }else{
	          var time1 = this.vbtime
	          var time2 = this.vetime
	        }
            var logininfo = JSON.parse(localStorage.logininfo) ;
              this.searchLoading = true;
              var params3 = qs.stringify({
                yhid:logininfo.id,
                xxid:logininfo.xxid,
                pageindex: this.pageindex,
                pagesize: this.pagesize,
                keyword :this.vkeyword,
                zt:this.visqy,
                btime:time1,
                etime:time2
      				});
              this.axios.post(this.$store.state.api + 'xfjl/list',params3 )
              .then( res => {
                console.log('11111',res)
                  let data = res.data.data;
                  let list = data.list;
                  this.total = data.totalPage;
                  this.dataList = list;
                  this.searchLoading = false;
              }).catch( res => {
//                console.log(res)
                  this.searchLoading = false;
              })
          },
          tableCellControl (scope) {
            //表格单元格控制CSS样式
                /*if (scope.row.id == 112 && scope.column.property == "iname") {
                    return {
                        color:"red",
                    }
                }else{
                    return {
                    	color:"green",
                    }
                }*/
           },
           handleSizeChange (val) {//每页显示条数触发事件
                this.pagesize = val;
                this.pageindex = 1;
                this.search();
            },
            handleCurrentChange (val) {//分页触发事件
                this.search();
            },
            checkSelect (selection, row) {//点击单选select触发事件
                console.log(selection, row)
                let strID = [];
                selection.forEach(function(v,i){
                    strID.push(v.id)
                })
                this.multipleDelNum = strID.join(",");
                if(this.multipleDelNum){
                	this.multipleDeleteDisabled = false
                }else{
                	this.multipleDeleteDisabled = true
                }
            },
            checkall (selection) {//点击全选select触发事件
                let strID = [];
                selection.forEach(function(v,i){
                    strID.push(v.id)
                })
                this.multipleDelNum = strID.join(",");
                if(this.multipleDelNum){
                	this.multipleDeleteDisabled = false
                }else{
                	this.multipleDeleteDisabled = true
                }
            },
            /* 组件的弹框  */
            componentsShow (type,data) { //显示组件
                // console.log(type,data)
                for ( let i in this.portComponents ) {
                    if (type == this.portComponents[i].type) {
                        this.portComponents[i].toggle = true;
                        this.portComponents[i].params = data;
                         if (this.portComponents[i].data.type == 'single') {
                            this.portComponents[i].data.index = data.row.id
                        }else if(this.portComponents[i].data.type == 'multiple'){
                            this.portComponents[i].data.index = this.multipleDelNum;
                        }else{
                            return;
                        }
                        return;
                    }
                }
            },
            componentsHide (setting) { //关闭组件
//              console.log(setting)
                for ( let i in this.portComponents ) {
                    if (setting.type == this.portComponents[i].type) {
                        this.portComponents[i].toggle = false;
                        if (!setting.cancel) {
                           this.search();
                        }
                        return;
                    }
                }
            }
        },
        computed: {
            ...mapState([
                'api'//域名
            ]),
//          multipleDeleteDisabled () {
////              console.log(this.multipleDelNum)
//              if (this.multipleDelNum) {
//                  return false;
//              }else{
//                  return true
//              }
//          }
        }
    }
</script>

<style lang="less" scoped>
    .port-page {
        font-size:12px;
        .btn {
            height: 30px;
            padding:0 10px;
        }
        .code-search {
             max-width: 130px;
            min-width: 100px;
            text-align: center;
            height: 50px;
            /*line-height: 50px;*/
            font-size: 12px;
            input{
              height: 40px !important;
            }
        }
        .class-page {
            text-align: left;
            margin-top:10px;
        }
        .search-item {
            display: inline-block;
        }
        .but1{
			width: 37%;
			height: 50px;
			float: left;
			line-height: 50px;
		}
		.search{
			width: 63%;
			height: 50px;
			line-height: 50px;
			float: right;
			text-align: right;
		}
		.search1{
			width: 50%;
			height: 50px;
			float: right;
			line-height: 50px;
			margin-right: 0px;
			text-align: right;
		}

		.el-button+.el-button {
            margin-left: 0px;
            margin-top: 5px;
        }
    }
</style>
